home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.5 KB | 94 lines | [TEXT/CWIE] |
- // ProgressView.cp
-
- #ifndef ProgressView_h
- #include "ProgressView.h"
- #endif
- #ifndef Progress_h
- #include "Progress.h"
- #endif
- #ifndef ViewMap_h
- #include "ViewMap.h"
- #endif
-
- ProgressView::ProgressView( const Progress& theProgress )
- : progress( theProgress ),
- ear( theProgress, *this, &ProgressView::UpdateSplit ),
- split( 0 )
- {
- }
-
- ProgressView::~ProgressView()
- {
- }
-
- void ProgressView::GainMapping()
- {
- UpdateSplit();
- View::GainMapping();
- }
-
- void ProgressView::ChangeBounds( Rectangle oldBounds )
- {
- UpdateSplit();
- View::ChangeBounds( oldBounds );
- }
-
- void ProgressView::UpdateSplit()
- {
- if ( !progress.TotalKnown() || !Mapped() )
- return;
-
- ViewMap map( *this, ViewMap::includeInvalid );
-
- int16 newSplit = progress.Fraction() * double( map.Bounds().Width() ) + 0.5;
-
- if ( split != newSplit )
- {
- split = newSplit;
- Draw( map );
- map.Validate();
- }
- }
-
- void ProgressView::Draw( const ViewMap& map ) const
- {
- Rectangle past( map.Bounds() );
- Rectangle future( map.Bounds() );
-
- past.right = past.left + split;
- future.left = past.right;
-
- PaintRect( &past );
- EraseRect( &future );
- }
-
- uint16 ProgressView::MinimumWidth() const
- {
- return 22;
- }
-
- uint16 ProgressView::MinimumHeight() const
- {
- return 3;
- }
-
- uint16 ProgressView::ReasonableWidth() const
- {
- return 188;
- }
-
- uint16 ProgressView::ReasonableHeight() const
- {
- return 11;
- }
-
- uint16 ProgressView::BestWidth() const
- {
- return 188;
- }
-
- uint16 ProgressView::BestHeight() const
- {
- return 11;
- }
-